<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("components4phpfull/jtdatepicker.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Resched_Reminder2 extends Page
{
       public $lblRec = null;
       public $edVendor = null;
       public $editType = null;
       public $edSchedule = null;
       public $hf_rem_time = null;
       public $hf_rem_by = null;
       public $hf_rem_hours = null;
       public $hf_every_hours = null;
       public $hf_every_date = null;
       public $hf_every_by = null;
       public $hf_due_date = null;
       public $hf_due_hours = null;
       public $JTJavaScript3 = null;
       public $JTJavaScript2 = null;
       public $JTJavaScript1 = null;
       public $edDesc = null;
       public $COMPLETION_TYPE = null;
       public $dpDue2 = null;
       public $dpDue = null;
       public $lblb4 = null;
       public $Label4 = null;
       public $cmbDaysMos = null;
       public $edRemind = null;
       public $cmbdm = null;
       public $ednum = null;
       public $lblkm = null;
       public $edEvery = null;
       public $lblEvery = null;
       public $chkRec = null;
       public $edDue = null;
       public $lblhr = null;
       public $lblHours = null;
       public $lblDueat = null;
       public $lblDueby = null;
       public $JTDivType = null;
       public $JTGroupBox1 = null;
       public $btnAddType = null;
       public $btnDelType = null;
       public $edType = null;
       public $listType = null;
       public $imgBack = null;
       public $hfsched = null;
       public $btnCancel = null;
       public $btnUpdate = null;
       public $btnShowType = null;
       public $compid = null;
       public $cmbcompletion = null;
       public $Label3 = null;
       public $cmbType = null;
       public $lblType = null;
       public $edPrice = null;
       public $lblFixedPrice = null;
       public $lblOrby = null;
       public $memoComments = null;
       public $lblComments = null;
       public $cmbVendor = null;
       public $Label2 = null;
       public $Label5 = null;
       public $cmbSchedule = null;
       public $Label1 = null;
       public $Image3 = null;
       public $hiddenReminder = null;
       public $JTSiteTheme1 = null;
       public $hiddenId = null;

       function btnCancelJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       window.close();
       <?php

       }

       function chkRecJSChange($sender, $params)
       {

       ?>
       //Add your javascript code here
       var chk = document.getElementById('chkRec').checked;
       if(chk==true)
       {
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var every = document.getElementById('lblEvery_outer');
       var ednum = document.getElementById('ednum_outer');
       var dm = document.getElementById('cmbdm_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');
       if(track=='Date' || track=='Time')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'visible';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('ednum_outer').style.visibility='visible';
       document.getElementById('cmbdm_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       every.style.left = '334px';
       ednum.style.left = '392px';
       dm.style.left = '472px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Km";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Hours";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       if(chk==false)
       {
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');

       if(track=='Date' || track=='Time')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'visible';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '334px';
       b4.style.left = '212px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function Resched_Reminder2JSLoad($sender, $params)
       {

       ?>
       var chk = document.getElementById('chkRec').checked;
       if(chk==true)
       {
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var every = document.getElementById('lblEvery_outer');
       var ednum = document.getElementById('ednum_outer');
       var dm = document.getElementById('cmbdm_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');
       if(track=='Date' || track=='Time')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'visible';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('ednum_outer').style.visibility='visible';
       document.getElementById('cmbdm_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       every.style.left = '334px';
       ednum.style.left = '392px';
       dm.style.left = '472px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Km";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Hours";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       if(chk==false)
       {
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');

       if(track=='Date' || track=='Time')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'visible';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '334px';
       b4.style.left = '212px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       //completionWindow();
       <?php

       }

       function cmbScheduleJSChange($sender, $params)
       {

       ?>
       var chk = document.getElementById('chkRec').checked;
       if(chk==true)
       {
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var every = document.getElementById('lblEvery_outer');
       var ednum = document.getElementById('ednum_outer');
       var dm = document.getElementById('cmbdm_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');
       if(track=='Date' || track=='Time')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'visible';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('ednum_outer').style.visibility='visible';
       document.getElementById('cmbdm_outer').style.visibility='visible';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       every.style.left = '334px';
       ednum.style.left = '392px';
       dm.style.left = '472px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Km";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='visible';
       document.getElementById('edEvery_outer').style.visibility='visible';
       document.getElementById('lblkm_outer').style.visibility='visible';
       document.getElementById('lblkm').innerHTML="Hours";
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       every.style.left = '381px';
       ednum.style.left = '670px';
       dm.style.left = '750px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       if(chk==false)
       {
       document.getElementById('edEvery_outer').style.visibility='hidden';
       document.getElementById('lblEvery_outer').style.visibility='hidden';
       document.getElementById('lblkm_outer').style.visibility='hidden';
       document.getElementById('ednum_outer').style.visibility='hidden';
       document.getElementById('cmbdm_outer').style.visibility='hidden';

       var track = document.getElementById('cmbSchedule').value;
       var hr = document.getElementById('lblhr_outer');
       var km = document.getElementById('lblHours_outer');
       var dueat = document.getElementById('lblDueat_outer');
       var dueby = document.getElementById('lblDueby_outer');
       var b4 = document.getElementById('lblb4');
       var DaysMos = document.getElementById('cmbDaysMos_outer');
       var remind = document.getElementById('edRemind');

       if(track=='Date' || track=='Date')
       {
       //alert('date');
       document.getElementById('lblDueby').style.visibility = 'visible';
       document.getElementById('f-calendar-field-1').style.visibility = 'visible';
       document.getElementById('edDue_outer').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-2').style.visibility = 'visible';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'hidden';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'visible';
       document.getElementById('cmbDaysMos_outer').style.visibility='visible';
       document.getElementById('lblb4').innerHTML="before due date";
       remind.style.width='61px';
       hr.style.left = '224px';
       km.style.left = '224px';
       dueat.style.left = '150px';
       dueby.style.left = '56px';
       DaysMos.style.left = '212px';
       b4.style.left = '334px';
       }

       if(track=='Mileage')
       {
       //alert('mileage');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'hidden';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Km before due";
       remind.style.width='181px';
       hr.style.left = '224px';
       km.style.left = '334px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '334px';
       b4.style.left = '212px';
       }

       if(track=='Hours')
       {
       //alert('hours');
       document.getElementById('lblDueby').style.visibility = 'hidden';
       document.getElementById('f-calendar-field-1').style.visibility = 'hidden';
       document.getElementById('edDue_outer').style.visibility = 'visible';
       document.getElementById('f-calendar-field-2').style.visibility = 'hidden';
       document.getElementById('lblOrby').style.visibility = 'hidden';
       document.getElementById('lblDueat').style.visibility = 'visible';
       document.getElementById('lblhr').style.visibility = 'visible';
       document.getElementById('lblHours').style.visibility = 'visible';
       document.getElementById('f-calendar-trigger-2').style.visibility = 'hidden';
       document.getElementById('f-calendar-trigger-1').style.visibility = 'hidden';
       document.getElementById('cmbDaysMos_outer').style.visibility='hidden';
       document.getElementById('lblb4').innerHTML="Hours before due";
       remind.style.width='181px';
       hr.style.left = '334px';
       km.style.left = '224px';
       dueat.style.left = '56px';
       dueby.style.left = '150px';
       DaysMos.style.left = '400px';
       b4.style.left = '334px';
       }
       }
       <?php

       }


       function btnDelTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var TypeIndex = document.getElementById('listType').selectedIndex;
       var TypeValue = document.getElementById('listType')[TypeIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxType3(TypeValue,compider3);
       <?php

       }

       function btnAddTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addtype = document.getElementById('edType').value;
       var compider = document.getElementById('compid').value;
       AjaxType2(addtype,compider);
       document.getElementById('edType').value = " ";
       <?php

       }

       function btnShowTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivType').Show();
       document.getElementById('edType').value = " ";
       <?php

       }

       function cmbcompletionJSChange($sender, $params)
       {
       //echo $this->cmbcompletion->ajaxCall('CompletionChange');
       ?>
       completionWindow();
       return false;
       <?php

       }


       function cmbScheduleChange($sender, $params)
       {
       $schedule = $this->cmbSchedule->getItemIndex();

       if($schedule=='Date' || $schedule=='Time')
       {
       $this->lblDueby->Visible=true;
       $this->dpDue->Visible=true;
       $this->lblHours->Visible=false;
       $this->edDue->Visible=false;
       $this->dpDue2->Visible=false;
       $this->lblOrby->Visible=false;
       $this->lblDueat->Visible=false;
       }
       else if ($schedule=='Both')
       {
       $this->lblDueat->Visible=true;
       $this->edDue->Visible=true;
       $this->dpDue2->Visible=true;
       $this->lblOrby->Visible=true;
       $this->lblDueby->Visible=false;
       $this->dpDue->Visible=false;
       $this->lblHours->Visible=true;
       }
       else if ($schedule=='Hours/Km')
       {
       $this->dpDue2->Visible=false;
       $this->lblOrby->Visible=false;
       $this->lblDueby->Visible=false;
       $this->dpDue->Visible=false;
       $this->edDue->Visible=true;
       $this->lblDueat->Visible=true;
       $this->lblHours->Visible=true;
       }


       }


       function CompletionChange()
       {
       $completion = $this->cmbcompletion->getItemIndex();

       if($completion=="WorkOrder")
       {
        $this->cmbType->Clear();
        $result_type = mysql_query("select * from lookup_workorder_tbl where company_id='".$_SESSION['company_id']."' and category='type'");

          while($row_type = mysql_fetch_array($result_type))
          {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
          }
       }

       if($completion=="Payment")
       {
        $this->cmbType->Clear();
        $result_type = mysql_query("select * from lookup_expense_tbl where company_id='".$_SESSION['company_id']."' and category='types'");

          while($row_type = mysql_fetch_array($result_type))
          {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
          }
       }

       if($completion=="None")
       {
        $this->cmbType->Clear();
        $result_type = mysql_query("select * from lookup_expense_tbl where company_id='".$_SESSION['company_id']."' and category='types'");

          while($row_type = mysql_fetch_array($result_type))
          {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
          }
       }


       }



       function Resched_Reminder2Create($sender, $params)
       {
       $this->compid->Value = $_SESSION['company_id'];
       $veh_id = $_GET['veh'];
       $this->hiddenId->setValue($veh_id);
       $reminder_id = $_GET['reminder'];
       $this->hiddenReminder->setValue($reminder_id);

       $this->imgBack->setLink('check_reminder.php?veh='.$this->hiddenId->getValue());


       /*$this->cmbDesc->Clear();
       $result_desc = mysql_query("select * from lookup_workorder_tbl where category='task descriptions'");

        while($row_desc = mysql_fetch_array($result_desc))
        {
            $this->cmbDesc->AddItem($row_desc['value'], null, $row_desc['value']);
        }*/



       $query_reminder = "select * from veh_reminder_tbl where vehicle_id='".$this->hiddenId->getValue()."' and reminder_id='".$this->hiddenReminder->getValue()."'";
       $result_reminder_show = mysql_query($query_reminder)or die("SELECT REMINDER - " . mysql_error());
       $row_reminder = mysql_fetch_array($result_reminder_show);

       $sched_by = $row_reminder['schedule_by'];
       $this->hfsched->setValue($sched_by);

       $this->cmbVendor->ItemIndex = $row_reminder['vendor'];
       $this->edVendor->Text = $row_reminder['vendor'];
       $result_vendor = mysql_query("select vendor_name from vendor_tbl where company_id='".$_SESSION['company_id']."'");

        while($row_vendor = mysql_fetch_array($result_vendor))
        {
            $this->cmbVendor->AddItem($row_vendor['vendor_name'], null, $row_vendor['vendor_name']);
        }

        $this->cmbType->ItemIndex = $row_reminder['type'];
        $this->editType->Text = $row_reminder['type'];//note there's a field 'edType'
        $this->cmbType->AddItem('--Select--', null, '--Select--');
        $result_type = mysql_query("select * from lookup_reminder_tbl where company_id='".$_SESSION['company_id']."' AND category='type'");

        while($row_type = mysql_fetch_array($result_type))
        {
            $this->cmbType->AddItem($row_type['value'], null, $row_type['value']);
        }


       //list type
       $this->listType->Clear();
       $result_t = mysql_query("select * from lookup_reminder_tbl where company_id='".$_SESSION['company_id']."' AND category='type'");

        while($row_t = mysql_fetch_array($result_t))
        {
            $this->listType->AddItem($row_t['value'], null, $row_t['value']);
        }


       $result_veh = mysql_query("select * from vehicle_tbl where vehicle_id='".$this->hiddenId->getValue()."'");
       $row_veh = mysql_fetch_array($result_veh);
       $track = $row_veh['track_by'];

       $this->edSchedule->Text = $sched_by;
       $this->cmbSchedule->Clear();
       $this->cmbSchedule->AddItem($sched_by, null, $sched_by);
       //$this->cmbSchedule->AddItem('Mileage', null, 'Mileage');
       //$this->cmbSchedule->AddItem('Hours', null, 'Hours');
       /*if($track=='distance')
       {
       $this->cmbSchedule->AddItem('Mileage', null, 'Mileage');
       $this->cmbSchedule->ItemIndex = $sched_by;
       }

       if($track=='hours')
       {
       $this->cmbSchedule->AddItem('Hours', null, 'Hours');
       $this->cmbSchedule->ItemIndex = $sched_by;
       }*/
       //$this->cmbSchedule->AddItem('Mileage', null, 'Mileage');
       //$this->cmbSchedule->AddItem('Hours', null, 'Hours');

       $this->chkRec->Checked = false;
       $this->lblRec->Caption = "Non-recurring";
       if($row_reminder['recur_per_veh']=='1')
       {
        $this->chkRec->Checked = true;
        $this->lblRec->Caption = "Recurring";
       }
       if($row_reminder['flag_temp']=='1')
       {
        $this->chkRec->Checked = true;
        $this->lblRec->Caption = "Recurring";
       }

       $this->cmbdm->setItemIndex($row_reminder['every_by']);
       $this->cmbDaysMos->setItemIndex($row_reminder['rem_by']);

       $this->edDue->Text = $row_reminder['due_hours'];
       $this->dpDue->Text = $row_reminder['due_date'];

       $this->edDesc->Text = $row_reminder['description'];

       $this->edEvery->Text = $row_reminder['every_hours'];
       $this->ednum->Text = $row_reminder['every_date'];

       if($sched_by=='Mileage' || $sched_by=='Hours')
       $this->edRemind->Text = $row_reminder['rem_hours'];
       if($sched_by=='Date' || $sched_by=='Time')
       $this->edRemind->Text = $row_reminder['rem_time'];

       //$this->cmbSchedule->ItemIndex = $row_reminder['schedule_by'];
       $this->cmbVendor->ItemIndex = $row_reminder['vendor'];
       $this->cmbcompletion->ItemIndex = $row_reminder['completion_window'];

       $this->memoComments->Text = $row_reminder['comments'];

       /*$sched = $this->cmbSchedule->ItemIndex=$row_reminder['schedule_by'];
       if($sched=='Hours')
       {
       $this->dpDue2->Visible=false;
       $this->lblOrby->Visible=false;
       $this->lblDueby->Visible=false;
       $this->dpDue->Visible=false;
       $this->edDue->Text=$row_reminder['due_hours'];
       $this->lblDueat->Visible=true;
       $this->lblHours->Visible=true;
       }
       else if($sched=='Date')
       {
       $this->lblDueby->Visible=true;
       $this->dpDue->Visible=true;
       $this->dpDue->Text=$row_reminder['due_date'];
       $this->lblHours->Visible=false;
       $this->edDue->Visible=false;
       $this->dpDue2->Visible=false;
       $this->lblOrby->Visible=false;
       $this->lblDueat->Visible=false;
       }
       else
       {
       $this->lblDueat->Visible=true;
       $this->edDue->Visible=true;
       $this->edDue->Text=$row_reminder['due_hours'];
       $this->dpDue2->Visible=true;
       $this->dpDue2->Text=$row_reminder['due_date'];
       $this->lblOrby->Visible=true;
       $this->lblDueby->Visible=false;
       $this->dpDue->Visible=false;
       $this->lblHours->Visible=true;
       }*/

       //$this->edPrice->Text = $row_reminder['price'];
       $this->memoComments->Text = $row_reminder['comments'];
       $this->cmbcompletion->setItemIndex($row_reminder['completion_window']);
       $this->edDesc->Text = $row_reminder['description'];
       $this->cmbType->setItemIndex($row_reminder['type']);

       $this->hf_due_hours->setValue($row_reminder['due_hours']);
       $this->hf_due_date->setValue($row_reminder['due_date']);
       $this->hf_every_by->setValue($row_reminder['every_by']);
       $this->hf_every_date->setValue($row_reminder['every_date']);
       $this->hf_every_hours->setValue($row_reminder['every_hours']);
       $this->hf_rem_hours->setValue($row_reminder['rem_hours']);
       $this->hf_rem_by->setValue($row_reminder['rem_by']);
       $this->hf_rem_time->setValue($row_reminder['rem_time']);
       }



       function btnUpdateClick($sender, $params)
       {
       $hours_save = null;
       $date_save = null;
       $cmbSched = $this->cmbSchedule->getItemIndex();
       if($cmbSched=='Date' || $cmbSched=='Time')
       {
       $date_save = $this->dpDue->getText();
       }
       if($cmbSched=='Hours' || $cmbSched=='Mileage')
       {
       $hours_save = $this->edDue->Text;
       }
       if($cmbSched=='Both')
       {
       $hours_save = $this->edDue->Text;
       $date_save = $this->dpDue->getText();
       }

       if($cmbSched=='Mileage' || $cmbSched=='Hours')
       {
         $save_rem = "rem_hours = '".$this->edRemind->Text."',";
       }
       if($cmbSched=='Time' || $cmbSched=='Date')
       {
         $save_rem = "rem_by = '".$this->cmbDaysMos->getItemIndex()."',rem_time = '".$this->edRemind->Text."',";
       }
       if($this->chkRec->Checked == true)
       $recurring = '1';
       if($this->chkRec->Checked == false)
       $recurring = '0';

       $sched = $this->cmbSchedule->getItemIndex();

       if($recurring=='1')
       {
       if($sched=='Mileage' || $sched=='Hours')
       {
        $every_hours = $this->edEvery->Text;
        $every_date = '';
        $every_by = '';
       }
       if($sched=='Date' || $sched=='Time')
       {
        $every_hours = '';
        $every_date = $this->ednum->Text;
        $every_by = $this->cmbdm->getItemIndex();
       }

       $query_reminder = "select * from veh_reminder_tbl where vehicle_id='".$this->hiddenId->getValue()."' and reminder_id='".$this->hiddenReminder->getValue()."'";
       $result_reminder_show = mysql_query($query_reminder)or die("SELECT REMINDER - " . mysql_error());
       $row_reminder = mysql_fetch_array($result_reminder_show);
       $re_num = $row_reminder['times_resched'];
       $total = $re_num + 1;

       /*$query_update = "update veh_reminder_tbl set
       recur_per_veh = '1',
       schedule_by = '".$cmbSched."',
       due_hours = '".$hours_save."',
       due_date = '".$date_save."',
       every_hours = '".$every_hours."',
       every_date = '".$every_date."',
       every_by = '".$every_by."',
       ".$save_rem."
       completion_window = 'WorkOrder',
       type = '".$this->cmbType->getItemIndex()."',
       description = '".$this->edDesc->Text."',
       vendor = '".$this->cmbVendor->getItemIndex()."',
       comments = '".$this->memoComments->Text."',
       times_resched = '".$total."'
       where vehicle_id ='".$this->hiddenId->getValue()."' and reminder_id = '".$this->hiddenReminder->getValue()."'";*/
       $query_update = "update veh_reminder_tbl set
       due_hours = '".$hours_save."',
       due_date = '".$date_save."',
       ".$save_rem."
       every_hours = '".$every_hours."',
       every_date = '".$every_date."',
       every_by = '".$every_by."',
       times_resched = '".$total."'
       where vehicle_id ='".$this->hiddenId->getValue()."' and reminder_id = '".$this->hiddenReminder->getValue()."'";
       }

       if($recurring=='0')
       {
       $query_update = "update veh_reminder_tbl set
       due_hours = '".$hours_save."',
       due_date = '".$date_save."',
       ".$save_rem."
       times_resched = '".$total."'
       where vehicle_id ='".$this->hiddenId->getValue()."' and reminder_id = '".$this->hiddenReminder->getValue()."'";
       }
       mysql_query($query_update)or die ("UPDATE VEHICLE REMINDER-".mysql_error());




       $flag_check = '0';

       $query_check = "SELECT due_hours,due_date,every_hours,every_date,every_by,rem_hours,rem_by,rem_time,recurring_id
       FROM veh_reminder_tbl WHERE reminder_id='".$this->hiddenReminder->getValue()."'";
       $result_check = mysql_query($query_check) or die("SELECT CHECK ".mysql_error());
       $row_check = mysql_fetch_array($result_check);

       if($row_check['recurring_id']>0)
       {
       if($this->hf_rem_time->getValue()!=$row_check['rem_time'])
       $flag_check = '1';
       if($this->hf_rem_by->getValue()!=$row_check['rem_by'])
       $flag_check = '1';
       if($this->hf_rem_hours->getValue()!=$row_check['rem_hours'])
       $flag_check = '1';
       if($this->hf_every_by->getValue()!=$row_check['every_by'])
       $flag_check = '1';
       if($this->hf_every_date->getValue()!=$row_check['every_date'])
       $flag_check = '1';
       if($this->hf_every_hours->getValue()!=$row_check['every_hours'])
       $flag_check = '1';
       if($this->hf_due_date->getValue()!=$row_check['due_date'])
       $flag_check = '1';
       if($this->hf_due_hours->getValue()!=$row_check['due_hours'])
       $flag_check = '1';

       if($flag_check=='1')
       {
        $resched_count_minus = $total - 1;
        $query_remove_link = "UPDATE veh_reminder_tbl SET template_id='0',recurring_id='0'
        WHERE vehicle_id ='".$this->hiddenId->getValue()."' AND reminder_id = '".$this->hiddenReminder->getValue()."'";
        mysql_query($query_remove_link) or die("UPDATE REMOVE LINK ".mysql_error());
       }
       if($flag_check=='0')
       {
        $resched_count_minus = $total - 1;
        $query_revert = "UPDATE veh_reminder_tbl SET times_resched='".$resched_count_minus."'
        WHERE vehicle_id ='".$this->hiddenId->getValue()."' AND reminder_id = '".$this->hiddenReminder->getValue()."'";
        mysql_query($query_revert) or die("UPDATE REVERT ".mysql_error());
       }
       }


       //redirect('check_reminder.php?veh='.$this->hiddenId->getValue());
       echo '<script language=javascript>
       alert("Reminder has been rescheduled");
       window.opener.location.reload();
       window.close()
       </script>';
       }

}

global $application;

global $Resched_Reminder2;

//Creates the form
$Resched_Reminder2=new Resched_Reminder2($application);

//Read from resource file
$Resched_Reminder2->loadResource(__FILE__);

//Shows the form
$Resched_Reminder2->show();

?>